package com.woniu.controller;


import com.woniu.commons.Result;
import com.woniu.controller.form.CompanyCount;
import com.woniu.controller.form.UserCount;
import com.woniu.service.IBmsTreasureCountService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 平台资产表 前端控制器
 * </p>
 *
 * @author Kevin Kwok
 * @since 2021-04-13
 */
@RestController
@RequestMapping("/count")
@Slf4j
public class BmsTreasureCountController {

    @Resource
    private IBmsTreasureCountService bmsTreasureCountService;

    @RequiresPermissions({"经营统计"})
    @GetMapping("/company/{type}")
    public Result company(@PathVariable("type") String type){
        List<CompanyCount> company = bmsTreasureCountService.company(type);
        int total = bmsTreasureCountService.countAllTreasure(type);
        return new Result("200","success",total,company);
    }
    @RequiresPermissions({"消费管理"})
    @GetMapping("/personal/{uid}")
    public Result personal(@PathVariable("uid") Integer uid){
        int i = bmsTreasureCountService.countAllConsumed(uid);
        List<UserCount> personal = bmsTreasureCountService.personal(uid);
        return new Result("200","success",i,personal);
    }
}

